﻿using System.Linq;
using WS.EKA.Utilities;

namespace WS.EKA.DataAccess
{
    public class HelperContext
    {
        protected static IConfig Config { get { return ConfigFactory.CreateConfigInstance(); } }

        public static string GetSequenceId(string tableName, string prefixCode)
        {
            using (var ctx = new DBContextBase(Config.ConnectionString))
            {
                var result = ctx.Database.SqlQuery<string>("exec uspAutoGenerateCode @tableName={0}", tableName);
                return prefixCode+result.FirstOrDefault();
            }
        }
    }
}
